Skip to content

gh-145411: Add runtime (now: unix only) control to Tachyon#149958

Open
maurycy wants to merge 7 commits into
python:mainfrom
maurycy:tachyon-runtime-socket
Open

gh-145411: Add runtime (now: unix only) control to Tachyon#149958
maurycy wants to merge 7 commits into
python:mainfrom
maurycy:tachyon-runtime-socket

Conversation

@maurycy
Copy link
Copy Markdown
Contributor

@maurycy maurycy commented May 17, 2026

Only unix: for starters:

Control socket:
  --control URI         control socket URI (unix:<path>) (default: None)

Supported commands are enable, disable, ping, status and quit. Each command is confirmed with either ok or err.

Example session:

[1] 2026-05-17T21:18:38.400172000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % sudo -E ./python.exe -m profiling.sampling run --control unix:/tmp/tachyon.sock -r 666khz -m test test_asyncio &>/dev/null &
[1] 84494
2026-05-17T21:18:41.130015000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'ping' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:42.759758000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'status' | sudo nc -U /tmp/tachyon.sock
ok enabled=True 
2026-05-17T21:18:44.875693000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'enable' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:46.871140000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'disable' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:48.756932000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'enable' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:49.083766000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'zażółć gęślą jaźn' | sudo nc -U /tmp/tachyon.sock
err unknown_command
2026-05-17T21:18:50.670507000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'quit' | sudo nc -U /tmp/tachyon.sock
ok
[1]  + done       sudo -E ./python.exe -m profiling.sampling run --control  -r 666khz -m test 

Closes #149958

if conn in self._connections:
self._flush_connection(conn)

def _dispatch(self, conn, command):
Copy link
Copy Markdown
Contributor Author

@maurycy maurycy May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No dump / snapshot yet.

if getattr(args, 'control', None) is not None:
if args.subprocesses:
parser.error("--control is incompatible with --subprocesses.")
if os.name == "nt":
Copy link
Copy Markdown
Contributor Author

@maurycy maurycy May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't have access to Windows.


if getattr(args, 'control', None) is not None:
if args.subprocesses:
parser.error("--control is incompatible with --subprocesses.")
Copy link
Copy Markdown
Contributor Author

@maurycy maurycy May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pablogsal Proper communication with children would be very complex. Maybe we can just use signals for enabling and disabling them.

from .errors import ControlError, ControlURIError


class ProfilerControl:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to inject this into LiveCollector but the direction is clear.

@maurycy
Copy link
Copy Markdown
Contributor Author

maurycy commented May 17, 2026

@maurycy maurycy changed the title gh-145411: Add socket control to Tachyon gh-145411: Add runtime (now: unix only) control to Tachyon May 17, 2026

with _get_child_monitor_context(args, args.pid):
server = None
with ExitStack() as stack:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping should-be-soon-to-be-added signal (SIGUSR1, SIGUSR2 for enabling or disabling?) support in mind.

self.close_after_write = False


class ControlServer:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @maurycy, this looks really interesting. I think we should introduce an abstraction here to be able to implement other transport protocols. Most importantly, I think we will need named pipes on Windows, but it would also allow things like adding TCP transport later down the line.

I spoke with @pablogsal briefly about this and we agreed that ideally we'd have Windows support also included in this change. Do you think you could look into that? I can run Windows in a VM and may be able to help out, but I'm not sure when I'll be able to get around to it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on the abstraction, it would be great to have everything here. I’d also love to see the snapshot command in this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants